﻿using System;
using Assets.Scripts.GtsScripts;
using MoonSharp.Interpreter;
using UnityEngine;

namespace Lua
{
	// Token: 0x020002F4 RID: 756
	[MoonSharpUserData]
	public class Morphs
	{
		// Token: 0x06001254 RID: 4692 RVA: 0x00080F1D File Offset: 0x0007F11D
		[MoonSharpHidden]
		public Morphs(EntityBase e)
		{
			if (e == null)
			{
				Debug.LogError("Creating Morphs with no entity");
			}
			this.entity = e;
			this.giantess = this.entity.GetComponent<Giantess>();
		}

		// Token: 0x06001255 RID: 4693 RVA: 0x00080F53 File Offset: 0x0007F153
		public int GetMorphCount()
		{
			return this.giantess.Morphs.Length;
		}

		// Token: 0x06001256 RID: 4694 RVA: 0x00080F64 File Offset: 0x0007F164
		public int FindMorphIndex(string morphName)
		{
			for (int i = 0; i < this.giantess.Morphs.Length; i++)
			{
				if (this.giantess.Morphs[i].Name.Equals(morphName, StringComparison.OrdinalIgnoreCase))
				{
					return i;
				}
			}
			return -1;
		}

		// Token: 0x06001257 RID: 4695 RVA: 0x00080FB4 File Offset: 0x0007F1B4
		public void ResetMorphs()
		{
			for (int i = 0; i < this.giantess.Morphs.Length; i++)
			{
				this.giantess.SetMorphValue(i, 0f);
			}
		}

		// Token: 0x06001258 RID: 4696 RVA: 0x00080FF0 File Offset: 0x0007F1F0
		public bool HasMorph(string morphName)
		{
			for (int i = 0; i < this.giantess.Morphs.Length; i++)
			{
				if (this.giantess.Morphs[i].Name.Equals(morphName, StringComparison.OrdinalIgnoreCase))
				{
					return true;
				}
			}
			return false;
		}

		// Token: 0x06001259 RID: 4697 RVA: 0x00081040 File Offset: 0x0007F240
		public void SetMorphValue(string morphName, float weight)
		{
			weight = ((weight >= 0f) ? ((weight <= 1f) ? weight : 1f) : 0f);
			for (int i = 0; i < this.giantess.Morphs.Length; i++)
			{
				if (this.giantess.Morphs[i].Name.Equals(morphName, StringComparison.OrdinalIgnoreCase))
				{
					this.giantess.SetMorphValue(i, weight);
					return;
				}
			}
			Debug.LogWarning("Failed to find morph \"" + morphName + "\".");
		}

		// Token: 0x0600125A RID: 4698 RVA: 0x000810E0 File Offset: 0x0007F2E0
		public void SetMorphValue(int index, float weight)
		{
			if (index <= 0 || index > this.giantess.Morphs.Length)
			{
				Debug.LogError("Index is out of range; index = " + index.ToString() + ", size = " + this.giantess.Morphs.Length.ToString());
				return;
			}
			weight = ((weight >= 0f) ? ((weight <= 1f) ? weight : 1f) : 0f);
			this.giantess.SetMorphValue(index, weight);
		}

		// Token: 0x0600125B RID: 4699 RVA: 0x00081180 File Offset: 0x0007F380
		public float GetMorphValue(string morphName)
		{
			for (int i = 0; i < this.giantess.Morphs.Length; i++)
			{
				if (this.giantess.Morphs[i].Name.Equals(morphName, StringComparison.OrdinalIgnoreCase))
				{
					return this.giantess.Morphs[i].Weight;
				}
			}
			Debug.LogError("Failed to find morph \"" + morphName + "\".");
			return 0f;
		}

		// Token: 0x0600125C RID: 4700 RVA: 0x00081200 File Offset: 0x0007F400
		public float GetMorphValue(int morphIndex)
		{
			if (morphIndex <= 0 || morphIndex > this.giantess.Morphs.Length)
			{
				Debug.LogError("Index is out of range; index = " + morphIndex.ToString() + ", size = " + this.giantess.Morphs.Length.ToString());
				return 0f;
			}
			return this.giantess.Morphs[morphIndex].Weight;
		}

		// Token: 0x040016CB RID: 5835
		private EntityBase entity;

		// Token: 0x040016CC RID: 5836
		private Giantess giantess;
	}
}
